package coderead.maven.job.bean;

import lombok.Data;

import java.util.Date;

@Data
public class ArtifactClass {
    private Integer id;
    private String fullClassName;
    private String artifact;

    private String version;

    private String describe;

    private Date dataLastModify;

    public void setVersion(String version) {
        this.version = version == null ? null : version.trim();
    }

    public void setDescribe(String describe) {
        this.describe = describe == null ? null : describe.trim();
    }

    public String getGroupId() {
        return artifact.split(":")[0];
    }

    public Object getArtifactId() {
        return artifact.split(":")[1];
    }

    public String getClassname() {
        if (fullClassName == null) {
            return null;
        } else {
            String[] s = fullClassName.split(" ");
            return s[1] + "." + s[0];
        }
    }

    public void setClassname(String classname) {
        if (classname == null) {
            fullClassName = null;
            return;
        }
        int i = classname.lastIndexOf(".");
        fullClassName = classname.substring(i + 1) + " " + classname.substring(0, i);
    }
}
